package com.monster.mechanic.utils.resources;

import java.io.File;


/**
 * Recover the paths from classes or paths which sometimes are more used.
 * 
 * @author ISAY ARENAS SOTO
 * @email isay.arenas@monster.com.mx
 *
 */
public class Paths {
	private static final String CLASSES_DIR = "classes";
	private static final String DB_FOLDER = "db";
	
	public static String getPathHibernateConfig() {
		return null;
	}

	public static String getPathClass(Class<?> clazz) {
		StringBuilder path = new StringBuilder(clazz.getProtectionDomain()
				.getCodeSource().getLocation().getPath());
		path = path.delete(path.toString().lastIndexOf(CLASSES_DIR)
				+ CLASSES_DIR.length(), path.length());
		path.append(File.separatorChar);
		return path.toString();
	}

	public static String getPathDB(Class<?> clazz) {
		StringBuilder path = new StringBuilder(getPathClass(clazz));
		path.append(DB_FOLDER);
		path.append(File.separatorChar);
		return path.toString();
	}

	public static String getPathXML(Class<?> clazz) {
		StringBuilder path = new StringBuilder(getPathClass(clazz));
		path.append("xml");
		path.append(File.separatorChar);
		return path.toString();
	}

	public static String getPathXMLConfig(Class<?> clazz) {
		StringBuilder path = new StringBuilder(getPathClass(clazz));
		path.append("xml/config");
		path.append(File.separatorChar);
		return path.toString();
	}
}
